/**
 * Created by yunpeng on 2014/12/4.
 */
var Table = require('../utils/commonDBConn').Table;

var City = function(province, city, firstletter) {
    this.province = province;
    this.city = city;
    this.firstletter = firstletter;
    if (typeof this.save != 'function') {//仅在第一次调用的初始化
        City.prototype.save = function(){
            var sql = 'insert into citys set ?';
            //var args = {username:this.username,nickname:this.nickname,password:this.password,usertype:this.usertype,integral:this.integral,active_id:this.active_id,did:this.did,createtime:this.createtime};
            db.execQuery(sql,this,function(result){
                console.log(result);
            });
        };
    }
    if (typeof this.getCityList!='function'){
        City.prototype.getCityList = function(callback){
            new Table('citys').queryAll(function(err,result){
                if(err){
                    callback(null);
                }else{
                    callback(result);
                }
            })
        }

    }
}
exports.City = City;